%{
	#include "gaxasm.y.tab.h"
%}
digit [0-9]
hexdigit [0-9a-fA-F]
letter [a-zA-Z_]
alnum {letter}|{digit}

id {letter}{alnum}*
directive \.{id}
register \${id}
label {id}:
hexnum 0x{hexdigit}+
decnum -?{digit}+
space [ \t]
comment #[^\n]*\n
string \"[^\"]*\"
line \n
invalid .
%{
	int yyline = 1;
	int yylval;
	char buf [256];
	char *yytag = (char *) &buf;
%}
%%
{space} ;
{comment} {yyline ++;}
{line} {yyline ++;}
{decnum} {sscanf (yytext, "%d", &yylval); return NUMBER;}
{hexnum} {sscanf (yytext, "%x", &yylval); return NUMBER;}
{directive} {strcpy (yytag, yytext); return lookup_directive (yytag);}
{register} {yylval = lookup_register (yytext); return REGISTER;}
{label} {strcpy (yytag, yytext); strtok (yytag, ":"); return LABEL;}
{id} {yylval = lookup_opcode (yytext); if (yylval < 0) {strcpy (yytag, yytext); return ID;} else return OPERATOR;}
{string} {strcpy (yytag, yytext + 1); strtok (yytag, "\""); return STRINGLITERAL;}
{invalid} {return INVALID;}
%%
int yywrap (void)
{
	return 1;
}

